#ifndef LOGGER_TEST_H
#define LOGGER_TEST_H

#include "include/gtest.h"
#include <thread>
#include "../Tool/include/ILogger.h"
#include "../Tool/include/Timer.h"
#include <atomic>

using namespace Tool;

TEST(Loger, LogerTest)
{
    int countTh = 4;
    int count = 1000000;
    Tool::ILogger::GetInstance()->SetOutputToConsole(false);
    std::vector<std::thread> threads;
    std::atomic<uint64_t> g_total_processed = 1;
    for(int i = 0;i < countTh; ++i)
    {
        threads.emplace_back([&](){
            for (int i = 0; i < count; ++i)
            {
                LOG_INFO("Thread Logger test %d", g_total_processed++);
            }
        });
    }
    LOG_INFO("Thread Logger test %d");
    Timer timer;
    for(auto& th : threads)
    {
        th.join();
    }
    std::cout << "线程数: " << countTh << " 日志数量: " << (count * countTh) / 10000 << "万 耗时: " << timer.Elapsed() << "ms" << std::endl;
}

#endif // LOGGER_TEST_H
